
#include "storagehandler.h"

StorageHandler::StorageHandler()
{
    this->graph_ = new Graph();
}

StorageHandler::~StorageHandler()
{
    if (this->graph_)
        delete this->graph_;
    this->graph_ = 0;
}

void StorageHandler::node(const boost::shared_ptr<const Osmium::OSM::Node>& currentNode)const
{

   this->graph_->addVertex(currentNode.get()->id(), currentNode.get()->lat(), currentNode.get()->lon());
}

void StorageHandler::way(const boost::shared_ptr<const Osmium::OSM::Way>& currentWay)const
{
    Osmium::OSM::WayNodeList list = currentWay.get()->nodes();
    for (int i = 1; i < list.size(); i++)
    {
        this->graph_->addEdge(list[i - 1].ref(), list[i].ref());
    }
}


void final()
{
}

Graph* StorageHandler::getGraph()
{
    return this->graph_;
}
